import requests


class IHRMApi:

    # 登录接口
    @classmethod
    def login_api(cls, body):
        url = "http://ihrm2-test.itheima.net/api/sys/login"
        headers = {"Content-Type": "application/json"}
        resp = requests.post(url=url, headers=headers, json=body)
        return resp

        pass

    # 添加员工接口
    @classmethod
    def add_user_api(cls, token, body):
        url = "http://ihrm2-test.itheima.net/api/sys/user"
        headers = {"Content-Type": "application/json", "Authorization": token}
        resp = requests.post(url=url, headers=headers, json=body)
        return resp

    # 查询员工接口
    @classmethod
    def query_user_api(cls, token, user_id):
        url = f"http://ihrm2-test.itheima.net/api/sys/user/{user_id}"
        headers = {"Authorization": token}
        resp = requests.get(url=url, headers=headers)
        return resp

    # 修改员工接口
    @classmethod
    def update_user_api(cls, token, user_id, body):
        url = f"http://ihrm2-test.itheima.net/api/sys/user/{user_id}"
        headers = {"Content-Type": "application/json", "Authorization": token}
        resp = requests.put(url=url, headers=headers, json=body)
        return resp

    # 删除员工接口
    @classmethod
    def del_user_api(cls, token, user_id):
        url = f"http://ihrm2-test.itheima.net/api/sys/user/{user_id}"
        headers = {"Authorization": token}
        resp = requests.delete(url=url, headers=headers)
        return resp
        pass

    pass
